package com.tjoris.bpmstudio;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public abstract class AbstractBpmOnAction extends AbstractBpmAction
{
	public AbstractBpmOnAction(final String id, final String name)
	{
		super(id, name);
	}
	
	public final boolean supportsOff()
	{
	    return false;
	}
	
	public final void performAction(final boolean on, final int value)
	{
		if (on)
		{
			performAction(value);
		}
	}
	
	public abstract void performAction(int value);
	
	protected int readData(final URL location) throws IOException
	{
		final InputStream inputStream = location.openStream();
		try
		{
			int result = 0;
			int ch = inputStream.read();
			while (ch >= '0'&& ch <= '9')
			{
				result = result * 10 + (ch - '0');
				ch = inputStream.read();
			}
			return result;
		}
		finally
		{
			inputStream.close();
		}
	}
}
